﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace StudentCouncil.Model.Models
{
    public partial class StudentContext : DbContext
    {
        public StudentContext()
        {
        }

        public StudentContext(DbContextOptions<StudentContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Renwu> Renwu { get; set; }
        public virtual DbSet<Association> Association { get; set; }
        public virtual DbSet<Associationstatus> Associationstatus { get; set; }
        public virtual DbSet<Attachment> Attachment { get; set; }
        public virtual DbSet<Competition> Competition { get; set; }
        public virtual DbSet<Competitionstatus> Competitionstatus { get; set; }
        public virtual DbSet<ComputingUnion> ComputingUnion { get; set; }
        public virtual DbSet<Department> Department { get; set; }
        public virtual DbSet<Grade> Grade { get; set; }
        public virtual DbSet<Message> Message { get; set; }
        public virtual DbSet<Student> Student { get; set; }
        public virtual DbSet<StudentUnion> StudentUnion { get; set; }
        public virtual DbSet<Teacher> Teacher { get; set; }
        public virtual DbSet<User> User { get; set; }
        public virtual DbSet<VolunteerUnion> VolunteerUnion { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer("Server=.;Database=Student Council;Trusted_Connection=True;uid=sa;pwd=199725");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Association>(entity =>
            {
                entity.Property(e => e.Video).IsUnicode(false);

                entity.Property(e => e.Assaddress).IsUnicode(false);

                entity.Property(e => e.Asschairman).IsUnicode(false);

                entity.Property(e => e.Assname).IsUnicode(false);

                entity.Property(e => e.Zdteacher).IsUnicode(false);
            });

            modelBuilder.Entity<Associationstatus>(entity =>
            {
                entity.Property(e => e.Assaddress).IsUnicode(false);

                entity.Property(e => e.Asschairman).IsUnicode(false);

                entity.Property(e => e.Assname).IsUnicode(false);

                entity.Property(e => e.Zdteacher).IsUnicode(false);

                entity.Property(e => e.Phone).IsUnicode(false);

                entity.Property(e => e.Status).IsUnicode(false);

                entity.Property(e => e.Wendong).IsUnicode(false);

                entity.Property(e => e.Video).IsUnicode(false);
            });

            modelBuilder.Entity<Attachment>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();

                entity.Property(e => e.AttachmentName).IsUnicode(false);

                entity.Property(e => e.AttachmentType).IsUnicode(false);

                entity.Property(e => e.PhysicalPath).IsUnicode(false);

                entity.Property(e => e.Remark).IsUnicode(false);
            });

            modelBuilder.Entity<Competition>(entity =>
            {
                entity.Property(e => e.Bsaddress).IsUnicode(false);

                entity.Property(e => e.Bsmethod).IsUnicode(false);

                entity.Property(e => e.Bsname).IsUnicode(false);

                entity.Property(e => e.Bssponsor).IsUnicode(false);
            });

            modelBuilder.Entity<Competitionstatus>(entity =>
            {
                entity.Property(e => e.Bsaddress).IsUnicode(false);

                entity.Property(e => e.Bsmethod).IsUnicode(false);

                entity.Property(e => e.Bsname).IsUnicode(false);

                entity.Property(e => e.Bssponsor).IsUnicode(false);
                entity.Property(e => e.Status).IsUnicode(false);
                entity.Property(e => e.People).IsUnicode(false);
            });

            modelBuilder.Entity<ComputingUnion>(entity =>
            {
                entity.Property(e => e.Classes).IsUnicode(false);

                entity.Property(e => e.College).IsUnicode(false);

                entity.Property(e => e.Department).IsUnicode(false);

                entity.Property(e => e.Email).IsUnicode(false);

                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Posision).IsUnicode(false);

                entity.Property(e => e.Sex)
                    .IsUnicode(false)
                    .IsFixedLength();
            });

            modelBuilder.Entity<Department>(entity =>
            {
                entity.Property(e => e.DepartmentAdmin).IsUnicode(false);

                entity.Property(e => e.DepartmentMiaoshu).IsUnicode(false);

                entity.Property(e => e.DepartmentName).IsUnicode(false);

                entity.Property(e => e.DepartmentPhone).IsUnicode(false);
            });

            modelBuilder.Entity<Grade>(entity =>
            {
                entity.Property(e => e.DtName).IsUnicode(false);

                entity.Property(e => e.Dtimg).IsUnicode(false);

                entity.Property(e => e.Dttext).IsUnicode(false);

                entity.Property(e => e.DtVideo).IsUnicode(false);

                entity.Property(e => e.Dtplrimg).IsUnicode(false);

                entity.Property(e => e.Dtplrtext).IsUnicode(false);

                entity.Property(e => e.Dtplrtx).IsUnicode(false); 

                entity.Property(e => e.Dtfbtime).IsUnicode(false);
            });

            modelBuilder.Entity<Message>(entity =>
            {
                entity.Property(e => e.Messages).IsUnicode(false); 
                entity.Property(e => e.MeVideo).IsUnicode(false);
            });

            modelBuilder.Entity<Student>(entity =>
            {
                entity.Property(e => e.Address).IsUnicode(false);

                entity.Property(e => e.Classes).IsUnicode(false);

                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Password).IsUnicode(false);

                entity.Property(e => e.Position).IsUnicode(false);

                entity.Property(e => e.Sex)
                    .IsUnicode(false)
                    .IsFixedLength();
            });

            modelBuilder.Entity<StudentUnion>(entity =>
            {
                entity.HasKey(e => e.UnionId)
                    .HasName("PK_Student union_1");

                entity.Property(e => e.Classes).IsUnicode(false);

                entity.Property(e => e.College).IsUnicode(false);

                entity.Property(e => e.Email).IsUnicode(false);

                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Posision).IsUnicode(false);

                entity.Property(e => e.Sex).IsUnicode(false);
            });

            modelBuilder.Entity<Teacher>(entity =>
            {
                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Position).IsUnicode(false);

                entity.Property(e => e.Sex)
                    .IsUnicode(false)
                    .IsFixedLength();

                entity.Property(e => e.TeacherId).IsUnicode(false);
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.Property(e => e.Gender)
                    .IsUnicode(false)
                    .IsFixedLength();

                entity.Property(e => e.HeadImg).IsUnicode(false);

                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Password).IsUnicode(false);

                entity.Property(e => e.Roles).IsUnicode(false);

                entity.Property(e => e.StudentId).IsUnicode(false);
            });
            modelBuilder.Entity<Renwu>(entity =>
            {
                entity.Property(e => e.Rwname).IsUnicode(false);

                entity.Property(e => e.Rwthings).IsUnicode(false);

                entity.Property(e => e.Rwwenjian).IsUnicode(false);

                entity.Property(e => e.Rwimg).IsUnicode(false);
            });

            modelBuilder.Entity<VolunteerUnion>(entity =>
            {
                entity.Property(e => e.Classes).IsUnicode(false);

                entity.Property(e => e.College).IsUnicode(false);

                entity.Property(e => e.Department).IsUnicode(false);

                entity.Property(e => e.Name).IsUnicode(false);

                entity.Property(e => e.Posision).IsUnicode(false);

                entity.Property(e => e.Sex)
                    .IsUnicode(false)
                    .IsFixedLength();
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
